﻿$(document).ready(function() {
    $("#username").focus();
})
function onEnterDown() {
    if (window.event.keyCode == 13) {
        submit_login();
    }
}
function submit_login() {
    $.ajaxSetup({ cache: false });
    var admin_uname = $("#username").val();
    var admin_psw = $("#password").val();
    if (admin_uname == "") {
        alert("请输入登录账号！");
        $("#username").focus();
        return false
    }
    if (admin_psw == "") {
        alert("请输入登录密码！");
        $("#password").focus();
        return false
    }
    $.ajax({
        type: "get",
        url: "../../Service/SystemManageHandler.ashx?action=Login&paramName=" + escape(admin_uname) + "&paramPwd=" + admin_psw,
        eache: false,
        success: function(reg) {
            if (reg == "1") {
                alert("URL解析错误！");
                $("#username").val("");
                $("#password").val("");
                $("#username").focus();
                return false;
            }
            if (reg == "2") {
                alert("表单或地址栏中含有尝试注入的非法关键词！");
                $("#username").val("");
                $("#password").val("");
                $("#username").focus();
                return false;
            }
            if (reg == "3") {
                window.location.href = "index.aspx";
            }
            if (reg == "4") {
                alert("您输入的密码有误，请重新输入！");
                $("#password").val("");
                $("#password").focus();
                return false;
            }
        },
        error: function(jqXHR, textStatus, errorThrown) {
            alert(jqXHR.responseText);
            $("#username").val("");
            $("#password").val("");
            $("#username").focus();
        }
    });
}